package com.ruoyi.web.controller.mes;


import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.kt.mes.domain.StorageInRecord;
import com.kt.mes.service.IStorageInRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入库记录Controller
 *
 * @author lzc
 * @date 2021-01-25
 */
@RestController
@RequestMapping("/mes/Rkrecord")
public class StorageInRecordController extends BaseController
{
    @Autowired
    private IStorageInRecordService storageInRecordService;

    /**
     * 查询入库记录列表
     */
    @PreAuthorize("@ss.hasPermi('mes:Rkrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(StorageInRecord storageInRecord)
    {
        startPage();
        List<StorageInRecord> list = storageInRecordService.selectStorageInRecordList(storageInRecord);
        return getDataTable(list);
    }

    /**
     * 导出入库记录列表
     */
    @PreAuthorize("@ss.hasPermi('mes:Rkrecord:export')")
    @Log(title = "入库记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StorageInRecord storageInRecord)
    {
        List<StorageInRecord> list = storageInRecordService.selectStorageInRecordList(storageInRecord);
        ExcelUtil<StorageInRecord> util = new ExcelUtil<StorageInRecord>(StorageInRecord.class);
        return util.exportExcel(list, "Rkrecord");
    }

    /**
     * 获取入库记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:Rkrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(storageInRecordService.selectStorageInRecordById(id));
    }

    /**
     * 新增入库记录
     */
    @PreAuthorize("@ss.hasPermi('mes:Rkrecord:add')")
    @Log(title = "入库记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StorageInRecord storageInRecord)
    {
        return toAjax(storageInRecordService.insertStorageInRecord(storageInRecord));
    }

    /**
     * 修改入库记录
     */
    @PreAuthorize("@ss.hasPermi('mes:Rkrecord:edit')")
    @Log(title = "入库记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StorageInRecord storageInRecord)
    {
        return toAjax(storageInRecordService.updateStorageInRecord(storageInRecord));
    }

    /**
     * 删除入库记录
     */
    @PreAuthorize("@ss.hasPermi('mes:Rkrecord:remove')")
    @Log(title = "入库记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(storageInRecordService.deleteStorageInRecordByIds(ids));
    }
}